package com.example.demo.module.activemq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Queue;
import javax.jms.Topic;

@RestController
@RequestMapping("/api")
public class ActiveMqClient {

    @Autowired
    private JmsTemplate jmsTemplate;

    @Autowired
    private Topic topic;

    @Autowired
    private Queue queue;

    @RequestMapping("/send")
    public void send() {
        jmsTemplate.convertAndSend(this.topic, "发送的topic数据!");
        jmsTemplate.convertAndSend(this.queue, "发送的queue数据!");
    }
}